package edu.nf.supermarket.web.controller.app;

import edu.nf.supermarket.base.BaseController;
import edu.nf.supermarket.entity.Coupon;
import edu.nf.supermarket.entity.UserCoupon;
import edu.nf.supermarket.mapper.CouponMapper;
import edu.nf.supermarket.mapper.UserCouponMapper;
import edu.nf.supermarket.result.ResultVO;
import edu.nf.supermarket.service.CouponService;
import edu.nf.supermarket.service.UserCouponService;
import edu.nf.supermarket.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.time.LocalDateTime;


/**
 * @author gwf
 * @date 2025-06-17
 */
@RestController
@RequestMapping("/coupon")
public class CouponController extends BaseController {
    @Autowired
    private UserCouponService userCouponService;
    @Autowired
    private CouponService couponService;
    @Autowired
    private CouponMapper couponMapper;

    /**
     * 发送新用户优惠券
     * @param userId
     * @return
     */
    @PostMapping("/sendNewUserCoupon")
    public ResultVO<Void> sendNewUserCoupon(@RequestParam("userId") Integer userId){
        // 发送新用户优惠券
        userCouponService.issueNewUserCoupon(userId);

        return success();
    }

    /**
     * 获取新用户优惠券信息
     * @return
     */
    @GetMapping("/getNewUserCouponInfo")
    public ResultVO<Coupon> getNewUserCouponInfo(){
        return success(couponService.getNewUserCoupon());
    }
}
